<?php include('./templete/public/head.php') ?>
<body>
<hr class="bgcolor"/>
<!--发布金点子-->
<div class="fabu-main fabu-gonglue-main">
    <div class="main-content">
        <div class="c-list">
            <ul class="comm-table-view">
                <li class="table-view-cell">
                    <a>
                        <span class="title">标题</span>
                        <span class="line">|</span>
                        <span class="input"><input type="text" id="title"/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">地点</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="place" id="place" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">站外链接</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="link" id="link" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">活动人数</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="number" id="number" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">开始时间</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="begin_time" id="begin_time" value=""  readonly="readonly"/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">结束时间</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="end_time" id="end_time" value="" readonly="readonly"/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell table-view-cell2">
                    <a>
                        <span>活动描述</span>
                        <div class="fabu-text">
                            <textarea id="content"></textarea>
                        </div>
                    </a>
                </li>
                <li class="table-view-cell table-view-cell2">
                    <button type="button" class="layui-btn" id="_img_upload" style="display: none">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <a>
                        <span>相关图片</span>
                        <div class="fabu-upload">
                            <img src="_images/icon/upload.jpg" class="showPopover _img_show" onclick="add_img()"/>
                            <!--                            <img class="_img_show" class="showPopover" />-->
                        </div>
                    </a>
                    <input type="hidden" name="_img_url" id="_img_url" class="_img_url">
                </li>
            </ul>
            <div class="comm-btn comm-btn2 fabu-btn">
                <span class="color1 publish">发布</span>
            </div>
        </div>
    </div>
</div>
</body>

<script src="_js/plug/mui.picker.all.js"></script>
<script>

    function add_img() {
        document.getElementById('_img_upload').click();
    }
    $('.publish').click(function () {
        var title = $('#title').val();
        var place = $('#place').val();
        var number = $('#number').val();
        var begin_time = $('#begin_time').val();
        var end_time = $('#end_time').val();
        var content = $('#content').val();
        var link = $('#link').val();
        var img_url = $('#_img_url').val();
        console.log(number);
        if(isNaN(number)||number<2){
            layer.msg('活动人数请输入大于1的数字');
            return false;
        }
        if(!title){
            layer.msg('请输入标题');
            return false;
        }
        if(!place){
            layer.msg('请输入地点');
            return false;
        }
        if(!begin_time){
            layer.msg('请输入开始时间');
            return false;
        }
        if(!end_time){
            layer.msg('请输入结束时间');
            return false;
        }
        layer.msg('请稍等');
        var loading = layer.load(1, {shade: [0.4, '#000']}); //0代表加载的风格，支持0-2
        $.ajax({
            url:'<?php echo url("travel/publish_mate")?>',
            data:{
                title:title,
                place:place,
                number:number,
                begin_time:begin_time,
                end_time:end_time,
                content:content,
                link:link,
                img_url:img_url,
            },
            type:'post',
            success:function (data) {
                if(data.code==1){
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.href=data.url;
                    },1000);
                }else{
                    layer.msg(data.msg);
                    setTimeout(function () {
                        layer.closeAll();
                    }, 1000);
                }
            }
        })

    })
    $(function() {
        $("#begin_time").click(function() {
            var dtPicker = new mui.DtPicker({
                type: 'datetime'
            });
            dtPicker.show(function(selectItems) {
                var y = selectItems.y.text; //获取选择的年
                var m = selectItems.m.text; //获取选择的月
                var d = selectItems.d.text; //获取选择的日
                var h = selectItems.h.text;
                var i = selectItems.i.text;
                var date = y + "-" + m + "-" + d +' '+ h+':'+i;
                $("#begin_time").val(date);
            })
        });
    });
    $(function() {
        $("#end_time").click(function() {
            var dtPicker = new mui.DtPicker({
                type: 'datetime'
            });
            dtPicker.show(function(selectItems) {
                var y = selectItems.y.text; //获取选择的年
                var m = selectItems.m.text; //获取选择的月
                var d = selectItems.d.text; //获取选择的日
                var h = selectItems.h.text;
                var i = selectItems.i.text;
                var date = y + "-" + m + "-" + d +' '+ h+':'+i;
                $("#end_time").val(date);
            })
        });
    });
</script>
</html>